home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Carousel Volume 2 #1
/
carousel.iso
/
mactosh
/
hc
/
homeimpr.sit
/
Home Improvements
/
card_5642.txt
< prev
next >
Wrap
Text File
|
1988-09-19
|
6KB
|
207 lines
-- card: 5642 from stack: in
-- bmap block id: 6321
-- flags: 4000
-- background id: 6079
-- name: text editor
-- part contents for background part 11
----- text -----
Untitled
-- part contents for background part 1
----- text -----
on mouseUp
doMenu "New Card"
put "untitled" into field "file name"
send tabKey
end mouseUp
on mouseUp
global IOResult, theText
put empty into extension
put 0 into NoErr
put 1 into fsFromStart
put 100 into item 1 of wher
put 100 into item 2 of wher
put empty into rply
put TBxFile("SFGetFile",wher,"What file:",0,1,"TEXT",0,0) into rply
if IOResult <> noErr THEN
put "IO error on SFGetFile " & IOResult
exit mouseUp
end if
if item 1 of rply is false then exit mouseup
get item 4 of rply
put the value of it into theVRefNo
put item 6 of rply into pfname
put TBxFile("FSOpen",pfname, theVRefNo, 0) into refNo
if IOResult <> noErr THEN
put "IO error on FSOpen " & IOResult
exit mouseUp
end if
put empty into logEOF
put TBxFile("GetEOF",refNo, 0) into logEOF
if IOResult <> noErr THEN
put "IO error on GetEOF " & IOResult
exit mouseUp
end if
put the value of logEOF into Siz
If Siz>29990 Then
put Siz & " Characters in the file"
ask "File too large, start reading from:" with 0
if it is empty then exit mouseUp
put the value of it into startPt
if startPt>Siz then put Siz-29990 into startPt
put "reading from " & startPt
put TBxFile("SetFPos",refNo, fsFromStart, startPt) into io
if IOResult <> noErr THEN
put "IO error on SetFPos0 " & IOResult
put TBxFile("FSClose",refNo) into io
put TBxFile("FlushVol",NIL, theVRefNo) into io
answer "An IO error has occured."
exit mouseUp
end if
put " (partial)" into extension
put siz-startPt into siz
if siz>29990 then put 29990 into siz
hide the message window
end if
put empty into theText
put TBxFile("FSRead",refNo, siz, 0) into theText
if IOResult <> noErr then
put "IO error on Read " & IOResult
exit mouseUp
end if
put pfname & extension into field "file name"
put TBxFile("FSClose",refNo) into io
IF IOResult <> noErr THEN
put "IO error on Close " & IOResult
exit mouseUp
end if
put TBxFile("FlushVol",NIL, theVRefNo) into io
IF IOResult <> noErr THEN
put "IO error on Flush " & IOResult
exit mouseUp
end if
put theText into field "theText"
send mouseUp to field "stats"
clickField
end mouseUp
on mouseUp
global IOResult, theText
put field "file name" into pfname
put 0 into NoErr
put -43 into fnfErr
put 1 into fsFromStart
put 100 into item 1 of wher
put 100 into item 2 of wher
put empty into rply
put TBxFile("SFPutFile",wher,"Save Field as:",pfname,0,0) into rply
if IOResult <> noErr THEN
put "IO error on SFPutFile " & IOResult
exit mouseUp
end if
if item 1 of rply is false then exit mouseup
get item 4 of rply
put the value of it into theVRefNo
put item 6 of rply into pfname
put TBxFile("FSOpen",pfname, theVRefNo, 0) into refNo
if (IOResult <> noErr) AND (IOResult <> fnfErr) THEN
put "IO error on FSOpen " & IOResult
exit mouseUp
end if
if IOResult=fnfErr then
put TBxFile("Create",pfname, theVRefNo, "????","TEXT") into io
if IOResult <> noErr THEN
put "IO error on Create " & IOResult
exit mouseUp
end if
put TBxFile("FSOpen",pfname, theVRefNo, 0) into refNo
if IOResult <> noErr THEN
put "IO error on FSOpen " & IOResult
exit mouseUp
end if
else
put TBxFile("GetEOF",refNo, 0) into logEOF
if IOResult <> noErr THEN
put "IO error on GetEOF " & IOResult
exit mouseUp
end if
put TBxFile("SetFPos",refNo, fsFromStart, logEOF) into io
if IOResult <> noErr THEN
put "IO error on SetFPos " & IOResult
exit mouseUp
end if
end if
put field "theText" into theText
put the length of theText into Siz
put TBxFile("FSWrite",refNo, siz, theText) into io
if IOResult <> noErr then
put "IO error on Write " & IOResult
exit mouseUp
end if
put TBxFile("FSClose",refNo) into io
IF IOResult <> noErr THEN
put "IO error on Close " & IOResult
exit mouseUp
end if
put TBxFile("FlushVol",NIL, theVRefNo) into io
IF IOResult <> noErr THEN
put "IO error on Flush " & IOResult
exit mouseUp
end if
put pfname into field "File Name"
end mouseUp
on mouseUp
send tabKey
doMenu "Copy Text"
put "The text has been copied to the clipboard."
wait 50 ticks
hide the message window
clickField
end mouseUp
on mouseUp
printfield "field theText",2
end mouseUp
on mouseUp
answer "Ascending or Descending?" with ¬
"Cancel" OR "Descending" OR "Ascending"
if it is "Cancel" then exit mouseUp
put "A" into hang
if it is "Descending" then put "D" into hang
put field "theText" into thingg
put empty into field "theText"
put sorter(thingg,hang) into field "theText"
send mouseUp to field "stats"
end mouseUp
on mouseUp
if the optionKey is down then
get the short name of this card
if it is "text edit" then
answer "You cannot delete the first text edit card"
exit mouseUp
end if
answer "Delete this card?" with "Cancel" or "OK"
if it is "Cancel" then exit mouseUp
doMenu "Delete Card"
go to prev card
end if
put empty into field "theText"
put empty into field "stats"
put "Untitled" into field "file name"
doMenu "Compact Stack"
send mouseUp to field "stats"
clickField
end mouseUp
-- part contents for background part 10
----- text -----
5300 chars
188 lines